package com.zhengjiang.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author zhengjiang
 * @version 1.0.0
 * @description
 * @date 2021/6/3
 **/
public class MyClassTest {
    public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
        Method[] methods = Class.forName("com.zhengjiang.annotation.MyClass").getMethods();
        for (Method m : methods){
           if(m.isAnnotationPresent(MyTag.class)){
               m.invoke(null);
           }
        }

        try {
            Annotation[] annos = Class.forName("com.zhengjiang.annotation.MyClass").getMethod("info2").getAnnotations();
            for (Annotation a :annos)
                System.out.println(a);


        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
}
